import store2 from "store2";

const initialState = {
  // 控制 Sider 是否收起
  collapsed: store2.get("collapsed") || false,
};

export const reducer = (state = initialState, action: any) => {
  switch (action.type) {
    case "setCollapsed":
      // 持久化存储一下
      store2.set("collapsed", action.payload);
      return {
        ...state,
        collapsed: action.payload,
      };
    default:
      return state;
  }
};
